package homework.exp02;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;
import java.util.regex.Pattern;

public class B {
    static Scanner cin = null;

    static {
        try {
            cin = new Scanner(new FileInputStream(new File("B.in")));
        } catch (IOException e) {
            cin = new Scanner(System.in);
        }
    }

    final static String ID = "^[a-zA-Z_][a-zA-Z0-9_]*$";

    public static void main(String[] args) {
        int T = Integer.parseInt(cin.nextLine());
        while (T-- > 0 && cin.hasNextLine()) {
            String id = cin.nextLine().trim();
            if (Pattern.matches(ID, id)) {
                System.out.println("Y");
            } else {
                System.out.println("N");
            }
        }
        if (cin != null) cin.close();
    }


}